package com.aidong.util;

/**
 * Created by john on 16-11-2.
 */
import com.aidong.dao.wills.PssProductCodeDao;
import com.aidong.model.wills.PssProductCodeAndProvider;
import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

@Repository
public class ProductUtil {
    private static Logger log = Logger.getLogger(ProductUtil.class);
    @Resource
    PssProductCodeDao pssProductCodeDao;

    public ProductUtil() {
    }

    public PssProductCodeAndProvider getProductInfo(String productCode) {
        new PssProductCodeAndProvider();
        String sql = "select pc.ProductCode, pc.PurcPrice, pt.ProviderCode \n from PssProductCode pc \n left outer join PssPurccontract pt on pc.DefaultContract=pt.ContractCode \n where pc.ProductCode = :p1 ";
        PssProductCodeAndProvider baseProuct = (PssProductCodeAndProvider)this.pssProductCodeDao.getBySql(PssProductCodeAndProvider.class, sql, new Object[]{productCode});
        if(baseProuct == null) {
            baseProuct = new PssProductCodeAndProvider();
        }

        return baseProuct;
    }
}
